package cn.scut.post.dao;

import cn.scut.post.pojo.Collect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PostCollectDao extends BaseMapper<Collect> {
    @Update("insert into collect values(#{collect.postid},#{collect.openid})")
    void insertUserCollect(@Param("collect") Collect collect);

    @Select("select * from collect where openid=#{openid}")
    List<Collect> selectAllCollect(String openid);

    @Select("select count(*) from collect where postid=#{postid} and openid=#{openid}")
    int selectOneCollect(String postid, String openid);

    @Update("delete from collect where postid=#{postid} and openid=#{openid}")
    int deleteUserCollect(String postid, String openid);
}
